package com.kcl.dfss;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;

import com.kcl.dfss.utils.ApplicationData;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

public class WelcomeActivity extends Activity {

	private Set<String> set = null;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		setContentView(R.layout.activity_welcome);

		
		Timer timer = new Timer();
		TimerTask task = new TimerTask() {
			@Override
			public void run() {
				SharedPreferences setting = getSharedPreferences("first_install", 0);
				/*setting.edit().putString("WIFI_NAME", "MyCamera").commit();
				setting.edit().putString("WIFI_PWD", "87654321").commit();
				String apname = setting.getString("WIFI_NAME", "MyCamera");
				String appwd = setting.getString("WIFI_PWD", "87654321");*/
				boolean user_first = setting.getBoolean("FIRST",true);
				set = new HashSet<String>();
				set.add(ApplicationData.app_version);
				setting.edit().putStringSet("appset", set).commit();
				if(user_first){
//					setting.edit().putBoolean("FIRST", false).commit();
//					WiFiManagerUtils.setWifiApEnabled(WelcomeActivity.this,true, apname, appwd);
					Intent intent = new Intent(WelcomeActivity.this,GuideActivity.class);
					startActivity(intent);
					finish();
				}else{
//					WiFiManagerUtils.setWifiApEnabled(WelcomeActivity.this,true, apname, appwd);
					Intent intent = new Intent();
					intent.setClass(WelcomeActivity.this, MainActivity.class);
					intent.putExtra("flag", 0);
					startActivity(intent);
					finish();
				} 
			}
		};
		timer.schedule(task, 2000*1);
	}
}
